#include "SaveToFile.h"
#include "support.h"

SaveToFile::SaveToFile(const QString &directory) : Filter(1, 0), counter(1), directory(directory)
{

}


SaveToFile::~SaveToFile(void)
{
}

void SaveToFile::Process()
{
	if (!inputs[0]->data)
		return;

	QImage image = MatToQImage(*inputs[0]);
	QString filename = QString(directory).append(QString("%1").arg(QString::number(counter),3,QChar('0')).append(".png"));

	bool res = image.save(filename);

	counter++;
}

void SaveToFile::ProcessInvalid()
{
	Filter::ProcessInvalid();

	counter++;
}
